home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic 4 Database How-To
/
Visual Basic 4 Database - How-to (The Waite Group)(1995).iso
/
control.fr_
/
control.fr
Wrap
Text File
|
1995-04-03
|
15KB
|
465 lines
VERSION 4.00
Begin VB.Form frmControl
BackColor = &H00C0C0C0&
Caption = "Set Report Printing Options"
ClientHeight = 5025
ClientLeft = 1050
ClientTop = 1530
ClientWidth = 6540
ForeColor = &H00000000&
Height = 5430
Left = 990
LinkTopic = "Form1"
ScaleHeight = 5025
ScaleWidth = 6540
Top = 1185
Width = 6660
Begin VB.Timer tmrReady
Interval = 500
Left = 2760
Top = 4320
End
Begin VB.CommandButton cmdPrint
Caption = "Print &Report"
Enabled = 0 'False
Height = 495
Left = 3720
TabIndex = 21
Top = 4320
Width = 1215
End
Begin VB.CommandButton cmdQuit
Caption = "&Quit"
Height = 495
Left = 5040
TabIndex = 22
Top = 4320
Width = 1215
End
Begin VB.HScrollBar hsbCopies
Height = 270
LargeChange = 10
Left = 3000
Max = 100
Min = 1
TabIndex = 13
Top = 3000
Value = 1
Width = 1935
End
Begin VB.ComboBox lstFileType
BackColor = &H00FFFFFF&
Height = 300
Left = 2160
Style = 2 'Dropdown List
TabIndex = 20
Top = 3720
Width = 2775
End
Begin VB.TextBox txtReportToPrint
BackColor = &H00C0C0C0&
Height = 285
Left = 2160
TabIndex = 1
Top = 360
Width = 2775
End
Begin VB.CommandButton cmdNewReport
Caption = "&Select File"
Height = 300
Left = 5040
TabIndex = 2
Top = 360
Width = 1215
End
Begin VB.CommandButton cmdFileName
Caption = "Change &File"
Height = 300
Left = 5040
TabIndex = 18
Top = 3360
Width = 1215
End
Begin VB.TextBox txtFileName
BackColor = &H00C0C0C0&
Height = 285
Left = 2160
TabIndex = 17
Top = 3360
Width = 2775
End
Begin VB.ComboBox lstDestination
BackColor = &H00FFFFFF&
Height = 300
Left = 2160
Style = 2 'Dropdown List
TabIndex = 15
Top = 2640
Width = 2775
End
Begin VB.TextBox txtCopies
BackColor = &H00C0C0C0&
Height = 285
Left = 2160
ReadOnly = -1 'True
TabIndex = 12
TabStop = 0 'False
Text = "1"
Top = 3000
Width = 735
End
Begin Threed.SSFrame frmConnect
Height = 1695
Left = 360
TabIndex = 23
Top = 720
Width = 4935
_version = 65536
_extentx = 8705
_extenty = 2990
_stockprops = 14
caption = "Connect String"
forecolor = -2147483640
Begin VB.TextBox txtConnect
BackColor = &H00FFFFFF&
Height = 285
Index = 0
Left = 1800
TabIndex = 4
Top = 240
Width = 2775
End
Begin VB.TextBox txtConnect
BackColor = &H00FFFFFF&
Height = 285
Index = 1
Left = 1800
TabIndex = 6
Top = 600
Width = 2775
End
Begin VB.TextBox txtConnect
BackColor = &H00FFFFFF&
Height = 285
Index = 2
Left = 1800
TabIndex = 8
Top = 960
Width = 2775
End
Begin VB.TextBox txtConnect
BackColor = &H00FFFFFF&
Height = 285
Index = 3
Left = 1800
TabIndex = 10
Top = 1320
Width = 2775
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
BackColor = &H00C0C0C0&
Caption = "&Data Source Name:"
Height = 255
Left = 240
TabIndex = 3
Top = 240
Width = 1500
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
BackColor = &H00C0C0C0&
Caption = "&User ID:"
Height = 255
Left = 240
TabIndex = 5
Top = 600
Width = 1500
End
Begin VB.Label Label4
Alignment = 1 'Right Justify
BackColor = &H00C0C0C0&
Caption = "&Password:"
Height = 255
Left = 240
TabIndex = 7
Top = 960
Width = 1500
End
Begin VB.Label Label5
Alignment = 1 'Right Justify
BackColor = &H00C0C0C0&
Caption = "D&B Qualifier:"
Height = 255
Left = 240
TabIndex = 9
Top = 1320
Width = 1500
End
End
Begin VB.Label lblFileType
Alignment = 1 'Right Justify
BackColor = &H00C0C0C0&
Caption = "&Output file type:"
Height = 255
Left = 360
TabIndex = 19
Top = 3720
Width = 1695
End
Begin VB.Label Label10
Alignment = 1 'Right Justify
BackColor = &H00C0C0C0&
Caption = "Report to print:"
Height = 255
Left = 360
TabIndex = 0
Top = 360
Width = 1695
End
Begin MSComDlg.CommonDialog cdFileName
Left = 2040
Top = 4320
_version = 65536
_extentx = 847
_extenty = 847
_stockprops = 0
dialogtitle = "Report File Destination Name"
filter = "Text File (*.txt)|*.txt|Document (*.doc)|*.doc|All Files (*.*)|*.*"
End
Begin VB.Label lblFileName
Alignment = 1 'Right Justify
BackColor = &H00C0C0C0&
Caption = "Output file name:"
Height = 255
Left = 360
TabIndex = 16
Top = 3360
Width = 1695
End
Begin Crystal.CrystalReport CrystalReport1
Left = 1320
Top = 4320
_extentx = 741
_extenty = 741
_stockprops = 0
reportfilename = ""
destination = 0
windowleft = 100
windowtop = 100
windowwidth = 490
windowheight = 300
windowtitle = ""
windowborderstyle= 2
windowcontrolbox= -1 'True
windowmaxbutton = -1 'True
windowminbutton = -1 'True
copiestoprinter = 1
printfilename = ""
printfiletype = 0
selectionformula= ""
groupselectionformula= ""
connect = ""
username = ""
End
Begin VB.Label Label9
Alignment = 1 'Right Justify
BackColor = &H00C0C0C0&
Caption = "&Print destination:"
ForeColor = &H00000000&
Height = 255
Left = 360
TabIndex = 14
Top = 2640
Width = 1695
End
Begin VB.Label lblCopies
Alignment = 1 'Right Justify
BackColor = &H00C0C0C0&
Caption = "&Number of copies:"
Height = 255
Left = 360
TabIndex = 11
Top = 3000
Width = 1695
End
End
Attribute VB_Name = "frmControl"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdFileName_Click()
cdFileName.DefaultExt = "txt"
cdFileName.DialogTitle = "Report File Destination Name"
cdFileName.Filter = "Text File (*.txt)|*.txt|Document (*.doc)|*.doc|All Files (*.*)|*.*"
cdFileName.ShowOpen
txtFileName.Text = cdFileName.FileName
End Sub
Private Sub cmdNewReport_Click()
cdFileName.DefaultExt = "rpt"
cdFileName.DialogTitle = "Select Report File"
cdFileName.Filter = "Report File (*.rpt)|*.rpt|All Files (*.*)|*.*"
cdFileName.ShowOpen
txtReportToPrint.Text = cdFileName.FileName
End Sub
Private Sub cmdPrint_Click()
'Since the button is enabled, we're okay to print
CrystalReport1.Action = 1
End Sub
Private Sub cmdQuit_Click()
End
End Sub
Private Sub Form_Load()
'Build the list control lists
lstDestination.AddItem "0: Print window"
lstDestination.AddItem "1: Printer"
lstDestination.AddItem "2: File"
lstDestination.ListIndex = 0
lstFileType.AddItem "0: Fixed field width"
lstFileType.AddItem "1: Tab delimited, with quotes"
lstFileType.AddItem "2: Space delimited"
lstFileType.AddItem "3: Data interchange format (DIF)"
lstFileType.AddItem "4: Comma delimited"
lstFileType.AddItem "5: Reserved"
lstFileType.AddItem "6: Tab delimited, no quotes"
'Set the visibility of the appropriate controls
lstDestination_Click
'Center the form
frmControl.Move (Screen.Width - frmControl.Width) / 2, (Screen.Height - frmControl.Height) / 2
End Sub
Private Sub hsbCopies_Change()
txtCopies.Text = hsbCopies.Value
CrystalReport1.CopiesToPrinter = hsbCopies.Value
End Sub
Private Sub lstDestination_Click()
'Enable appropriate options, based on ListIndex
Select Case lstDestination.ListIndex
Case 0 'Print to window
lblFileName.ForeColor = &H404040
txtFileName.Enabled = False
txtFileName.Text = ""
cmdFileName.Enabled = False
lblFileType.ForeColor = &H404040
lstFileType.Enabled = False
lstFileType.Text = ""
lblCopies.ForeColor = &H404040
txtCopies.Enabled = False
txtCopies.Text = 1
hsbCopies.Value = 1
Case 1 'Print to printer
lblFileName.ForeColor = &H404040
txtFileName.Enabled = False
txtFileName.Text = ""
cmdFileName.Enabled = False
lblFileType.ForeColor = &H404040
lstFileType.Enabled = False
lstFileType.Text = ""
lblCopies.ForeColor = &H0&
txtCopies.Enabled = True
txtCopies.Text = 1
hsbCopies.Value = 1
Case 2 'Print to file
lblFileName.ForeColor = &H0&
txtFileName.Enabled = True
txtFileName.Text = ""
cmdFileName.Enabled = True
lblFileType.ForeColor = &H0&
lstFileType.Enabled = True
lstFileType.Text = ""
lblCopies.ForeColor = &H404040
txtCopies.Enabled = False
txtCopies.Text = 1
hsbCopies.Value = 1
End Select
End Sub
Private Sub lstFileType_Click()
'Can't use the Crystal Reports reserved value
If lstFileType.ListIndex = 5 Then
MsgBox "Reserved value not available. Please select another."
lstFileType.ListIndex = 0
lstFileType.Text = ""
Else
CrystalReport1.PrintFileType = lstFileType.ListIndex
End If
End Sub
Private Sub tmrReady_Timer()
'Check every half second to see if report is ready to print
'If it is, enable the Print Report command button
Dim Ready As Boolean
Ready = True
If Len(txtReportToPrint.Text) < 5 Then
Ready = False
End If
If lstDestination.ListIndex = 2 And (txtFileName.Text = "" Or lstFileType.Text = "") Then
Ready = False
End If
cmdPrint.Enabled = IIf(Ready, True, False)
End Sub
Private Sub txtConnect_LostFocus(Index As Integer)
'Something in one of the control array boxes changed,
'so rebuild the connect string
Dim Connect As String
If Len(txtConnect(0).Text) Then
Connect = "DSN=" & txtConnect(0).Text & ";"
End If
If Len(txtConnect(1).Text) Then
Connect = Connect & "UID=" & txtConnect(1).Text & ";"
End If
If Len(txtConnect(2).Text) Then
Connect = Connect & "PWD=" & txtConnect(2).Text & ";"
End If
If Len(txtConnect(3).Text) Then
Connect = Connect & "DSQ=" & txtConnect(3).Text & ";"
End If
CrystalReport1.Connect = Connect
End Sub
Private Sub txtReportToPrint_Change()
'Contents have changed, so reset cmdNewReport caption
If Len(txtReportToPrint.Text) Then
cmdNewReport.Caption = "&Change File"
CrystalReport1.ReportFileName = txtReportToPrint.Text
Else
cmdNewReport.Caption = "&Select File"
CrystalReport1.ReportFileName = ""
End If
End Sub
Private Sub txtFileName_Change()
'Contents have changed, so reset cmdFileName caption
'and set the PrintFileName property
If Len(txtFileName.Text) Then
cmdFileName.Caption = "Change &File"
CrystalReport1.PrintFileName = txtFileName.Text
Else
cmdFileName.Caption = "Select &File"
CrystalReport1.PrintFileName = ""
End If
End Sub